;; Utility functions
;;
;; Copyright 2011:
;; James McDermott <jamesmichaelmcdermott@gmail.com>
;; Mark Wagy <mark.wagy@gmail.com>
;;
;; This file is part of p-gen, a p-systems and evolutionary system
;; written in Clojure.
;;
;; p-gen is licensed under GNU GPL v3.
;;
;; http://code.google.com/p/p-gen/

(ns psystem.util)

;; prompt to enter object 
(defn prompt-read [prompt]
  (print (format "%s: " prompt))
  (flush)
  (read-line))

;; utility function to read a yes or not answer as boolean
(defn y-or-n-p [prompt]
  (= "y" (prompt-read prompt)))

(defn save-to-file [stuff filename]
      (spit filename (pr-str stuff)))

(defn load-from-file [filename]
  (read-string (slurp filename)))
 
(defn print-recs [recs]
  (doseq [rec recs]
	 (doseq [[k v] rec]
		(print (format "%s: %s\n" (name k) v)))))

